<template>
  <div class="comment-post">
    <van-field
      class="post-field"
      v-model.trim="messages"
      rows="2"
      autosize
      type="textarea"
      maxlength="50"
      placeholder="请输入留言"
      show-word-limit
    />
    <van-button
      class="post-btn"
      @click="onSendComments"
    >发布</van-button>
  </div>
</template>

<script>
export default {
  name: 'SendComment',
  props: {
    // 由父组件传递的文章ID
    target: {
      type: [String, Number, Object],
      required: true
    }
  },
  data () {
    return {
      // 用户发表评论内容
      messages: '',
      // 文章ID，对评论内容发表回复需要传递
      art_id: null
    }
  },
  methods: {
    onSendComments () {
      this.$toast.loading({
        message: '文章发布中...',
        forbidClick: true, // 背景点击禁用
        duration: 0 // 持续时间 默认2000
      })
    }
  }
}
</script>

<style scoped lang="less">
.comment-post {
  display: flex;
  align-items: center;
  padding: 32px 0 32px 32px;
  .post-field {
    background-color: #f5f7f9;
  }
  .post-btn {
    width: 150px;
    border: none;
    padding: 0;
    color: #6ba3d8;
    &::before {
      display: none;
    }
  }
}
</style>
